/**
* @description: 周赛314 t1
* @author hewei
* @date 2022/10/9 10:31
* @version 1.0
*/

public class HardestWorker {

    public int hardestWorker(int n, int[][] logs) {
        int last = 0;
        int max = 0;
        int ans = 0;
        for (int i = 0; i < logs.length; ++i) {
            int[] log = logs[i];
            int id = log[0];
            int time = log[1];
            if (time - last > max) {
                max = time - last;
                ans = id;
            } else if (time  - last == max) {
                ans = Math.min(ans, id);
            }
            last = time;
        }
        return ans;
    }
}
